<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Event Handling</title>
    <link rel="stylesheet" href="gettingStarted.css" type="text/css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" />
    <link rel="start" href="index.html" title="Getting Started with Replicated Berkeley DB Applications" />
    <link rel="up" href="introduction.html" title="Chapter 1. Introduction" />
    <link rel="prev" href="permmessages.html" title="Permanent Message Handling" />
    <link rel="next" href="txnapp.html" title="Chapter 2. Transactional Application" />
  </head>
  <body>
    <div xmlns="" class="navheader">
      <div class="libver">
        <p>Library Version 12.1.6.2</p>
      </div>
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">Event Handling</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="permmessages.html">Prev</a> </td>
          <th width="60%" align="center">Chapter 1. Introduction</th>
          <td width="20%" align="right"> <a accesskey="n" href="txnapp.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="sect1" lang="en" xml:lang="en">
      <div class="titlepage">
        <div>
          <div>
            <h2 class="title" style="clear: both"><a id="eventhandling"></a>Event Handling</h2>
          </div>
        </div>
      </div>
      <p>
            The replication system is capable of reporting a great many
            events to which your code might need to respond. To track and
            respond to these events, you implement a 
             
            <span>class</span>
            whose function it is to respond to events that happen within
            the DB library.  
        </p>
      <p>
            In order to respond to events, you must write your application as an
            implementation of
            <code class="classname">com.sleepycat.db.EventHandler</code>.
            This class gives you a series of methods within which you can
            detect and respond to various events that occur in your DB
            code. Note that some of these are necessary for events beyond
            those required for replication. In this section, however, we
            only discuss some of the replication-specific events.
        </p>
      <p>
            Some of the more commonly handled replication events are
            described below.  For a complete list of events, see the

            
            
            <span>
                <code class="classname">com.sleepycat.db.EventHandler</code>
                javadoc page.
            </span>
        </p>
      <div class="itemizedlist">
        <ul type="disc">
          <li>
            <p>
                    
                    <code class="methodname">EventHandler.handleRepClientEvent()</code>
                </p>
            <p>
                    The local environment is now a replica.
                </p>
          </li>
          <li>
            <p>
                    
                    <code class="methodname">EventHandler.handleRepLocalSiteRemovedEvent()</code>
                </p>
            <p>
                    The local Replication Manager site has been removed from the group.
                </p>
          </li>
          <li>
            <p>
                    
                    <code class="methodname">EventHandler.handleRepMasterEvent()</code>
                </p>
            <p>
                    The local environment is now a master.
                </p>
          </li>
          <li>
            <p>
                    
                    <code class="methodname">EventHandler.handleRepNewMasterEvent()</code>
                </p>
            <p>
                    An election was held and a new environment was made a
                    master.  However, the current environment 
                    <span class="emphasis"><em>is not</em></span> the master. This event exists so
                    that you can cause your code to take some unique action
                    in the event that the replication groups switches
                    masters.
                </p>
          </li>
          <li>
            <p>
                    
                    <code class="methodname">EventHandler.handleRepPermFailedEvent()</code>
                </p>
            <p>
                    The Replication Manager did not receive enough acknowledgements to
                    ensure the transaction's durability within the
                    replicationg group.  The Replication Manager has therefore flushed
                    the transaction to the master's local disk for storage.
                </p>
            <p>
                    How the Replication Manager knows whether the acknowledgements it has
                    received is determined by the acknowledgement policy you have set
                    for your applicaton. See 
                    <a class="xref" href="fwrkpermmessage.html#fmwrkpermpolicy" title="Identifying Permanent Message Policies">Identifying Permanent Message Policies</a> 
                    for more information.
                </p>
          </li>
          <li>
            <p>
                    
                    <code class="methodname">EventHandler.handleRepSiteAddedEvent()</code>
                </p>
            <p>
                    A new Replication Manager site has joined the replication group.
                </p>
          </li>
          <li>
            <p>
                    
                    <code class="methodname">EventHandler.handleRepSiteRemovedEvent()</code>
                </p>
            <p>
                    An existing Replication Manager site has been removed from the replication group.
                </p>
          </li>
          <li>
            <p>
                    
                    <code class="methodname">EventHandler.handleRepStartupDoneEvent()</code>
                </p>
            <p>
                    The replica has completed startup synchronization and
                    is now processing log records received from the master.
                </p>
          </li>
        </ul>
      </div>
      <p>
            For an example of how to use this callback, see
            <a class="xref" href="fwrkmasterreplica.html#determinestate" title="Determining State">Determining State</a>
        </p>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="permmessages.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="introduction.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="txnapp.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">Permanent Message Handling </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> Chapter 2. Transactional Application</td>
        </tr>
      </table>
    </div>
  </body>
</html>
